d411058586ee21846db8d366806eb13fd4b6bd68,plugins/IntelliLang/java-support/org/intellij/plugins/intelliLang/pattern/PatternValidator.java,IntroduceVariableFix,applyFix,#Project#ProblemDescriptor#,294

Before Change



    public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
      final RefactoringActionHandler handler = JavaRefactoringActionHandlerFactory.getInstance().createIntroduceVariableHandler();
      handler.invoke(project, new PsiElement[]{myExpr}, DataManager.getInstance().getDataContext());
      // how to automatically annotate the variable after it has been introduced?
    }
  }

After Change



    public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor) {
      final RefactoringActionHandler handler = JavaRefactoringActionHandlerFactory.getInstance().createIntroduceVariableHandler();
      final AsyncResult<DataContext> dataContextContainer = DataManager.getInstance().getDataContextFromFocus();
      dataContextContainer.doWhenDone(new AsyncResult.Handler<DataContext>() {
        public void run(DataContext dataContext) {
          handler.invoke(project, new PsiElement[]{myExpr}, dataContext);
        }
      });
      // how to automatically annotate the variable after it has been introduced?
    }
  }